package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.business.entity.CAdviceFeedback;
import cn.stylefeng.guns.modular.business.model.params.CAdviceFeedbackParam;
import cn.stylefeng.guns.modular.business.model.result.CAdviceFeedbackResult;
import cn.stylefeng.guns.modular.business.service.CAdviceFeedbackService;
import cn.stylefeng.guns.modular.business.service.MessageNoticeService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 控制器
 *
 * @author pzp
 * @Date 2019-07-25 11:59:53
 */
@Controller
@RequestMapping("/cAdviceFeedback")
public class CAdviceFeedbackController extends BaseController {

    private String PREFIX = "/business/cAdviceFeedback";

    @Autowired
    private CAdviceFeedbackService cAdviceFeedbackService;

    @Autowired
    private MessageNoticeService messageNoticeService;

    /**
     * 跳转到主页面
     *
     * @author pzp
     * @Date 2019-07-25
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/cAdviceFeedback.html";
    }

    /**
     * 新增页面
     *
     * @author pzp
     * @Date 2019-07-25
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/cAdviceFeedback_add.html";
    }

    /**
     * 回复页面
     *
     * @author pzp
     * @Date 2019-07-25
     */
    @RequestMapping("/reply")
    public String reply(String adviceId, Model model) {
        CAdviceFeedbackResult cAdviceFeedbackResult=cAdviceFeedbackService.findById(adviceId);
        model.addAttribute("cAdviceFeedback",cAdviceFeedbackResult);
        return PREFIX + "/cAdviceFeedback_edit.html";
    }

    /**
     * 新增接口
     *
     * @author pzp
     * @Date 2019-07-25
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(CAdviceFeedbackParam cAdviceFeedbackParam) {
        this.cAdviceFeedbackService.add(cAdviceFeedbackParam);
        return ResponseData.success();
    }

    /**
     * 回复接口
     *
     * @author pzp
     * @Date 2019-07-25
     */
    @RequestMapping("/replyAdvice")
    @ResponseBody
    public ResponseData replyAdvice(CAdviceFeedbackParam cAdviceFeedbackParam) {
        messageNoticeService.add("意见反馈通知",cAdviceFeedbackParam.getReply(),"1");
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author pzp
     * @Date 2019-07-25
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(CAdviceFeedbackParam cAdviceFeedbackParam) {
        this.cAdviceFeedbackService.delete(cAdviceFeedbackParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author pzp
     * @Date 2019-07-25
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(CAdviceFeedbackParam cAdviceFeedbackParam) {
        CAdviceFeedback detail = this.cAdviceFeedbackService.getById(cAdviceFeedbackParam.getAdviceId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author pzp
     * @Date 2019-07-25
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(CAdviceFeedbackParam cAdviceFeedbackParam) {
        return this.cAdviceFeedbackService.findPageBySpec(cAdviceFeedbackParam);
    }

}


